package com.am.file.service.impl;

import com.am.api.dto.MeetingFileDto;
import com.am.common.utils.BeanUtils;
import com.am.file.domain.po.MeetingFiles;
import com.am.file.mapper.MeetingFilesMapper;
import com.am.file.service.IMeetingFilesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cq
 * @since 2025-02-12
 */
@Service
public class MeetingFilesServiceImpl extends ServiceImpl<MeetingFilesMapper, MeetingFiles> implements IMeetingFilesService {
@Autowired
    MeetingFilesMapper meetingFilesMapper;
    @Override
    public Collection<Long> saveFile(List<MeetingFileDto> meetingFileDtos) {
        System.out.println(meetingFileDtos);
        ArrayList<Long> ids = new ArrayList<Long>();
        try {
            for (MeetingFileDto meetingFileDto : meetingFileDtos) {
                MeetingFiles meetingFiles = BeanUtils.copyBean(meetingFileDto, MeetingFiles.class);
                meetingFiles.setId(null);
                meetingFilesMapper.insert(meetingFiles);
                ids.add(meetingFiles.getId());
            }
            return ids;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }

    }
}
